<template>
    <div>
        <el-table
                :data="pageData"
                style="width: 100%"
                :default-sort = "{prop: 'date', order: 'descending'}"

        >
            <el-table-column
                    prop="logid"
                    label="LogID"
                    sortable
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="logcontent"
                    label="操作"
                    sortable
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="logdatetime"
                    label="时间"
                    width="180"
                    sortable>
<!--                    :formatter="formatter">-->
            </el-table-column>

        </el-table>
        <el-pagination
                background
                layout="prev, pager, next"
                :total="(this.tableData[0].length/6)*10"
                @current-change="nexts"
        >
        </el-pagination>
    </div>
</template>

<script>
    import {LookLog} from "../../network/admin";

    export default {
        name: "LookLog",
        data() {
            return {
                tableData: [],
                pageData:[],
                currents:1
            }
        },
        methods: {
            formatter(row, column) {
                return row.address;
            },
            nexts(val){
                // console.log(current)
                val = val*6;
                this.pageData = this.tableData[0].slice(val-6,val)
                // for (let i of this.pageData){
                //     i.logdatetime = new Date(i.logdatetime).toLocaleDateString()
                // }
            },
        },
        mounted() {
            LookLog(this.$store.state.auths).then(res => {
                if (res[0].logid > 0 ){
                    this.tableData.push(res);
                    console.log(this.tableData[0]);
                    this.nexts(1)
                }
            })
        }
    }
</script>

<style scoped>

</style>
